<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('每日跟进')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse" >
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <label>项目类型：</label>
                            <select name="projectType" th:with="type=${@dict.getType('eb_project_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>项目标签：</label>
                            <select id="projectLabel" name="projectLabel" th:with="type=${@dict.getType('eb_project_label')}" class="selectpicker" data-none-selected-text="所有" multiple>

                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>项目阶段：</label>
                            <select name="projectStage" th:with="type=${@dict.getType('eb_project_stage')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset();$('#projectLabel').selectpicker('val',['noneSelectedText'])"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:inline="javascript">

    var editFlag = [[${@permission.hasPermi('manage:project:edit')}]];
    var removeFlag = [[${@permission.hasPermi('manage:project:remove')}]];
    var prefix = ctx + "manage/approveLog";

    var projectTypeDatas = [[${@dict.getType('eb_project_type')}]];
    var projectLabelDatas = [[${@dict.getType('eb_project_label')}]];
    var approveStatusDatas = [[${@dict.getType('eb_approve_status')}]];
    var projectStageDatas = [[${@dict.getType('eb_project_stage')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            detailUrl: prefix + "/detail/{id}",
            sortName: "updateTime",
            sortOrder: "desc",
            modalName: "项目信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'projectType',
                    title: '项目类型',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectTypeDatas, item.projectType);
                    }
                },
                {
                    field: 'projectLabel',
                    title: '项目标签',
                    formatter: function(value, item, index) {
                        var projectLabel = item.projectLabel;
                        var labelStr = "";
                        if (projectLabel) {
                            var labelArray = projectLabel.split(",");
                            for (var i=0; i < labelArray.length; i++) {
                                labelStr = labelStr + " " + $.table.selectDictLabel(projectLabelDatas, labelArray[i]);
                            }
                        }
                        return labelStr;
                    }
                },
                {
                    field: 'projectStage',
                    title: '项目阶段',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectStageDatas, item.projectStage);
                    }
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="addLog(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>项目跟进</a> ');
                        actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="showLog(\'' + row.projectId + '\')"><i class="fa fa-search"></i>项目动态</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function addLog(projectId) {
        var url = prefix + '/addLog/' + projectId;
        $.modal.open("每日跟进", url);
    }

    function showLog(projectId) {
        var url = prefix + '/showLog/' + projectId;
        $.modal.openTab("每日跟进", url, true);
    }
</script>
</body>
</html>